package com.lovely602.langchain4j.functioncalling.controller;


import cn.hutool.core.date.DateUtil;
import com.lovely602.langchain4j.functioncalling.service.FunctionAssistant;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author lizhixing
 */
@Slf4j
@RestController
@RequestMapping(value = "/functioncalling")
public class FunctionCallingChatController {

    @Resource(name = "invoicingAssistant")
    private FunctionAssistant invoicingAssistant;

    @Resource(name = "weatherAssistant")
    private FunctionAssistant weatherAssistant;

    /**
     * 开具发票
     */
    @GetMapping(value = "/invoice")
    public String invoice(@RequestParam(value = "msg", defaultValue = "开张发票,公司：尚硅谷教育科技有限公司 税号：atguigu533 金额：668.12") String msg) {
        String chat = invoicingAssistant.chat(msg);

        System.out.println(chat);

        return "success : " + DateUtil.now() + "\t" + chat;
    }

    /**
     * 查询天气
     */
    @GetMapping(value = "/weather")
    public String weather(@RequestParam(value = "msg", defaultValue = "查询101010100明天的天气") String msg) {
        String chat = weatherAssistant.chat(msg);

        System.out.println(chat);

        return "success : " + DateUtil.now() + "\t" + chat;
    }

}
